package com.linsen.uaa.feign;

import com.linsen.core.common.constant.ProviderConstant;
import com.linsen.core.common.util.Result;
import com.linsen.core.satoken.handler.StpInterfaceHandler;
import com.linsen.uaa.provider.feign.IAuthFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhaoyong
 * @date 2023/3/15
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class AuthFeignClient implements IAuthFeignClient {
    private final StpInterfaceHandler stpInterfaceHandler;

    @Override
    @GetMapping(ProviderConstant.PROVIDER_USER)
    public Result getUser() {
        return Result.data(this.stpInterfaceHandler.getUser());
    }

    @Override
    @GetMapping(ProviderConstant.PROVIDER_USER_ID)
    public Result getUserByUserId(String userId) {
        return Result.data(this.stpInterfaceHandler.getUserByLoginId(userId));
    }

    @Override
    @GetMapping(ProviderConstant.PROVIDER_USER_TOKEN)
    public Result getUserByTokenValue(String tokenValue) {
        return Result.data(this.stpInterfaceHandler.getUserByTokenValue(tokenValue));
    }
}
